using System;
using System.Collections.Generic;
using System.Text;

namespace GraphFS
{
	public struct GeoRectangle
	{
		public static GeoRectangle Empty = new GeoRectangle(0, 0, 0, 0);
		private GeoPoint location;
		public GeoPoint Location
		{
			get { return location; }
			set { location = value; }
		}

		private GeoSize size;
		public GeoSize Size
		{
			get { return size; }
			set { size = value; }
		}


		public GeoRectangle(double lat, double lon, double width, double height)
		{
			location = new GeoPoint(lat, lon);
			size = new GeoSize(width, height);
		}
		public GeoRectangle(GeoPoint locationStart, GeoPoint locationEnd)
		{
			this.location = locationStart;
			this.size = locationEnd - locationStart;
		}
		public GeoRectangle(GeoPoint location, GeoSize size)
		{
			this.location = location;
			this.size = size;
		}

		public bool Contains(GeoPoint p)
		{

			if (
				(p.Lat >= location.Lat && p.Lat <= location.Lat + size.Width) &&
				(p.Lon >= location.Lon && p.Lon <= location.Lon + size.Height)
				)
			{
				return true;
			}
			return false;
		}


		public bool Contains(GeoRectangle r)
		{
			if (
				(r.location.Lat >= location.Lat && r.location.Lat + r.size.Width <= location.Lat + size.Width) &&
				(r.location.Lon >= location.Lon && r.location.Lon + r.size.Height <= location.Lon + size.Height)
				)
			{
				return true;
			}

			return false;
		}











		public override string ToString()
		{
			return String.Format("GeoRectangle {{ Location:{0}, Size:{1} }}", location, size);
		}

	}
}
